<!DOCTYPE html>
<html>

	<head>
		<title>大朴 后台管理</title>
		<meta charset="UTF-8">
		<script src="__ROOT__/Admin/Common/js/angular.min.js"></script>
		<script src="__ROOT__/Admin/Common/js/jquery-3.2.1.min.js"></script>
		<style type="text/css" rel="stylesheet">
			html,
			body {
				width: 100%;
				height: 100%;
				margin: 0;
				padding: 0;
				font-family: "lucida grande", "lucida sans unicode", lucida, helvetica, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
			}
			
			.header {
				height: 40px;
				width: 100%;
				background-color: #242424;
				position: fixed;
			}
			
			.header_title {
				line-height: 40px;
				margin-left: 60px;
				color: #fff;
				font-size: 15px;
			}
			
			.header_user {
				font-size: 12px;
				margin-left: 20px;
				color: #ccc;
			}
			
			.addinfo {
				width: 620px;
				height: 700px;
				padding-top: 20px;
				margin-left: auto;
				margin-right: auto;
				font-size: 13px;
			}
			
			.addinfo input {
				width: 450px;
				height: 28px;
				margin-bottom: 10px;
				outline: none;
				padding-left: 5px;
			}
			
			.addinfo span {
				display: inline-block;
				width: 150px;
			}
			
			.addinfo_btn {
				width: 450px;
				height: 35px;
				text-align: center;
				line-height: 35px;
				border: 1px solid #ccc;
				margin-left: 80px;
				margin-top: 20px;
				border-radius: 5px;
			}
			
			.addinfo_btn:hover {
				background-color: #36A0FB;
				color: #fff;
				border: 1px solid #36A0FB;
			}
			
			table {
				width: 1500px;
				margin-left: auto;
				margin-right: auto;
				margin-top: 10px;
				font-size: 13px;
				border-collapse: collapse;
				border-spacing: 0;
				margin-bottom: 50px;
				table-layout: fixed;
			}
			
			table td {
				border: 1px solid #ddd;
				padding: 0;
				width: 20%;
				white-space: nowrap;
				overflow: hidden;
				word-break: break-all;
				font-size: 12px;
				font-weight: 300;
				text-overflow: ellipsis;
			}
			
			table tr:hover {
				background-color: #36A0FB;
				color: #fff !important;
			}
			
			a {
				color: black;
				text-decoration: none;
			}
			.admin-title{
				background: lightskyblue;
				height: 100px;
				font-size: 30px;
				line-height: 150px;
				text-align: center;
			}
			textarea{
				width: 455px;
				height: 100px;
				outline: none;
				resize: none;
			}
		</style>

	</head>

	<body ng-app="myapp" ng-controller="mycontroller">
		<div class="header">
			<div class="header_title">
				<a href="###">后台管理系统</a><span class="header_user">欢迎你,{$Think.session.username}</span></div>
		</div>
		<div class="admin-title">
			{{bigtype}}--->{{middletype}}--->{{smalltype}}
		</div>
		<div class="addinfo">
			<div>
				<span>标题name </span><input id="name" type="text" ng-model="name" />
			</div>
			<div>
				<span>编号goodnumber </span><input id="number" type="text" ng-model="goodnumber" />
			</div>
			<div>
				<span>价格price </span><input id="price" type="text" ng-model="price" />
			</div>
			<div>
				<span>会员价格memberprice </span><input id="membeprice" type="text" ng-model="memberprice" />
			</div>
			<div>
				<span>销售量sellnum </span><input id="sellnum" type="text" ng-model="sellnum" />
			</div>
			<div>
				<span>评论量reviewnum</span><input id="reviewnum" type="text" ng-model="reviewnum" />
			</div>
			<div>
				<span>积分score </span><input id="score" type="text" ng-model="score" />
			</div>
			<div>
				<span>简介content </span><input id="content" type="text" ng-model="content" />
			</div>
			<div>
				<span>图片地址imgurl </span><textarea  id="imgurl" ng-model="imgurl" /></textarea>
			</div>
			<div>
				<span>类型type </span><input id="type" type="text" ng-model="type" />
			</div>
			<div>
				<span>详细图片detailimg </span><textarea  id="detailimg" ng-model="detailimg" /></textarea>
			</div>
			
			
			
			
			
			<div class="addinfo_btn" ng-click="add()">提交</div>
		</div>

		<div>
			<table  id="listtable">
				<tr style="text-align:center;font-size:15px;height:30px;color:#fff;background-color:#36A0FB;border:0;">
					<td style="width:40px">编号</td>
					<td style="width:100px;">ID</td>
					<td>商品编号</td>
					<td>标题</td>
					<td style="width:120px;">价格</td>
					<td>会员价格</td>
					<td>销售量</td>
					<td>评论量</td>
					<td>积分</td>
					<td style="width:120px;">简介</td>
					<td>图片地址</td>
					<td>类型</td>
					<td>详细图片</td>
					<td>操作</td>
				</tr>

				<tr ng-repeat="val in arr" style="text-align:center;height:26px;color:#4C4C4C;">
					<td>{{key+1}}</td>
					<td>{{val.id}}</td>
					<td>{{val.number}}</td>
					<td>{{val.name}}</td>
					<td>{{val.price}}</td>
					<td>{{val.memberprice}}</td>
					<td>{{val.sellnum}}</td>
					<td>{{val.reviewnum}}</td>
					<td>{{val.score}}</td>
					<td>{{val.content}}</td>
					<td>{{val.imgurl}}</td>
					<td>{{val.type}}</td>
					<td>{{val.detailimg}}</td>
					<td><a href="###" ng-click="del(val.id)">删除</a></td>
				</tr>

			</table>
		</div>
	</body>
	<script>
		var app = angular.module("myapp", []);
		app.controller("mycontroller", function($scope, $http) {
			$scope.name = "";
			$scope.goodnumber = "";
			$scope.price = "";
			$scope.memberprice = "";
			$scope.sellnum = "";
			$scope.reviewnum = "";
			$scope.score = "";
			$scope.content = "";
			$scope.imgurl = "";
			$scope.type = "";
			$scope.detailimg = "";
			
			
			
			$scope.bigtype="",
			$scope.middletype="",
			$scope.smalltype="",
			

			$scope.add = function() {
				$http({
					url: "__URL__/add",
					method: "POST",
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: "name=" + $scope.name + "&price=" + $scope.price + "&memberprice=" + $scope.memberprice + "&sellnum=" + $scope.sellnum + "&reviewnum=" + $scope.reviewnum + "&score=" + $scope.score + "&content=" + $scope.content +"&goodnumber=" + $scope.goodnumber + "&imgurl=" + $scope.imgurl + "&type=" + $scope.type +"&detailimg=" + $scope.detailimg ,
				}).success(function(res) {
					if(res.status == 1) {
						$scope.arr = res.data;
						$scope.name = "";
						$scope.goodnumber = "";
						$scope.price = "";
						$scope.memberprice = "";
						$scope.sellnum = "";
						$scope.reviewnum = "";
						$scope.score = "";
						$scope.content = "";
						$scope.imgurl = "";
						$scope.type = "";
						$scope.detailimg = "";
						
						
					} else {
						alert(res.info);
					}
				}).error(function(err) {
					console.log(err);
				})
			}

			$scope.del = function(num) {
				$http({
					url: "__URL__/del",
					method: "POST",
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data: "id=" + num
				}).success(function(res) {
					if(res.status == 1) {
						alert("删除成功");
						$scope.arr = res.data;
					} else {
						alert("系统错误");
					}
				}).error(function(err) {
					console.log(err);
				})
			}

			$http.get("__URL__/getgoodsData").success((res) => {
				$scope.arr = res.data;
				$scope.bigtype = res.bigtype;
				$scope.middletype = res.middletype;
				$scope.smalltype = res.smalltype;
			}).error((err) => {
				console.log(err);
			})

		})
	</script>

</html>